<!--付费判断-->
{php $shipinbiao = \Phpcmf\Service::M()->db->table('1_'.MOD_DIR.'_shipin_buy')->where('cid', $id)->where('uid', $member.uid)->get()->getRowArray();}
<!--积分判断-->

{if $shipinyuedumoshi == '1'}
	<!--免费阅读-->
	<div class="d-kuan d-shang-15 d-xia-10">
		{loop $shipin $i $c}
		<div class="d-kuan">
		<div class="">
			<div id="dplayer-{$i}-{$id}" class="d-shang-10 d-yuanjiao-10 "></div>
		</div>
		<div class="d-clear"></div>
		</div>
		{/loop}
	</div>
{elseif $shipinyuedumoshi == '2'}
<!--付费阅读-->
	{if $shipinbiao || $uid == $member.id || $member.is_admin}
		<div class="d-kuan d-shang-15 d-xia-10">
			{loop $shipin $i $c}
			<div class="d-kuan">
			<div class="">
				<div id="dplayer-{$i}-{$id}" class="d-shang-10 d-yuanjiao-10 "></div>
			</div>
			<div class="d-clear"></div>
			</div>
			{/loop}
		</div>
	{else}
		<div class="d-kuan d-shang-10 d-gao-378 d-wenzi-juzhong d-xia-15 d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
			<img src="{HOME_THEME_PATH}web/img/shipin1.png" width="60" height="60" style="margin-top: 70px;"/>
			<br>付费观看视频
			<br><span class="d-zitiyanse-hongse">{$shipinyuedujinbi}  元</span>
			<br>
			<a href="{dr_url(MOD_DIR.'/buyshipin/index', ['fid' => $ci->module['form']['son']['field']['shipinyuedujinbi']['id'],'id'=> $id])}">
			<div class="d-kuan-juzhong d-kuan-50 d-hanggao-30 d-wenzi-juzhong d-shang-5 d-wenzi-12 d-beijing-hei d-yuanjiao-20 d-zitiyanse-bai">
				购 买
			</div>
			</a>
		</div>
		
	{/if}
{elseif $shipinyuedumoshi == '3'}
	<!--积分阅读-->
	{if $shipinbiao || $uid == $member.id || $member.is_admin}
			<div class="d-kuan d-shang-15 d-xia-10">
				{loop $shipin $i $c}
				<div class="d-kuan">
				<div class="">
					<div id="dplayer-{$i}-{$id}" class="d-shang-10 d-yuanjiao-10 "></div>
				</div>
				<div class="d-clear"></div>
				</div>
				{/loop}
			</div>
		{else}
		    <div class="d-kuan d-shang-10 d-gao-378 d-wenzi-juzhong d-xia-15 d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
				<img src="{HOME_THEME_PATH}web/img/shipin1.png" width="60" height="60" style="margin-top: 70px;"/>
				<br>积分观看视频
				<br><span class="d-zitiyanse-hongse">{$shipinyuedujifen}  {SITE_SCORE}</span>
				<br>
				<a href="{dr_url(MOD_DIR.'/buyshipinjifen/index', ['fid' => $ci->module['form']['son']['field']['shipinyuedujifen']['id'],'id'=> $id])}">
				<div class="d-kuan-juzhong d-kuan-50 d-hanggao-30 d-wenzi-juzhong d-shang-5 d-wenzi-12 d-beijing-hei d-yuanjiao-20 d-zitiyanse-bai">
					购 买
				</div>
				</a>
			</div>
			
		{/if}
{/if}
<style>
	.dplayer-controller .dplayer-icons .dplayer-setting {
		display: none;
	}
	.dplayer-controller .dplayer-icons .dplayer-time, .dplayer-controller .dplayer-icons .dplayer-live-badge {
		display: none;
	}
	.dplayer.dplayer-mobile .dplayer-controller .dplayer-icons .dplayer-full .dplayer-full-in-icon {
		display: none;
	}
	.dplayer-controller .dplayer-icons.dplayer-icons-left .dplayer-icon {
		display: none;
	}
</style>

<script>
	{if $shipinbiao || $uid == $member.id || $member.is_admin || $shipinyuedumoshi == '1'}
	{loop $shipin $i $c}
		<?php
			$info = \Phpcmf\Service::C()->get_attachment($c.file);
			if (is_file($info['file'])) {
				$sell = 'ffmpeg -i '.$info['file'].' -r 30 -t 4 '.$info['file'].'.jpg';
				shell_exec($sell);
				// 这样就生成了一个.jpg的后缀缩略图
				//echo $info['url'].'.jpg';
			} else {
				// 文件不存在于本地磁盘
				$tuurl = '/www/wwwroot/weibo/public/uploadfile/shipin/';
				$sell = 'ffmpeg -i '.$info['url'].' -r 30 -t 4 '.$info['url'].'.webp';
				shell_exec($sell);
			}
		?>
		const dp{$i} = new DPlayer({
			container: document.getElementById('dplayer-{$i}-{$id}'),
			video: {
				url: '{dr_get_file($c.file)}',
				{if (is_file($info['file']))}
					pic: '{$info['url'].'.jpg'}',
				{else}
					pic: '{$info['url'].'.webp'}',
				{/if}
			},
		});
		var selectObj = $("#dplayer-{$i}-{$id}").children();
			
		//var video{$i} = $('.dplayer-video').parent().parent('#dplayer-{$i}'); //当前视频对象;
		var video{$i}{$id} = selectObj[1].childNodes[1];//当前视频对象;
		//$('#item1').parent('.parent1') document.querySelector(“p.lover”);
		//var video{$i} = document.getElementsByTagName(".dplayer-video");
		video{$i}{$id}.onloadedmetadata=function(res){
			//console.log('媒介元素的持续时间以及其他媒介数据已加载时运行脚本：',res);  
			//窗体
			var window_Width=window.innerWidth;
			var window_Height=window.innerHeight;  
			//console.log('窗体-宽度：',window_Width);
			//console.log('窗体-高度：',window_Height);
			//原视频
			var videoWidth=video{$i}{$id}.videoWidth;
			var videoHeight=video{$i}{$id}.videoHeight; 
			//console.log('原视频-宽度：',videoWidth);
			//console.log('原视频-高度：',videoHeight);
			//视频根据窗体自动缩放
			//公式-等比例缩放后的高=（缩放后的宽度/原始宽度）*原始高度
			var Box_videoWidth=window_Width*0.5;
			var Box_videoHeight=(window_Width/videoWidth)*videoHeight*0.5; //缩放后的高度
			//console.log('视频缩放-宽度：',Box_videoWidth);
			//console.log('视频缩放-高度：',Box_videoHeight);  
			//var total_height=window_Height-(that.topTitle_height+that.footNav_height);//视频容器总高度
	
			//console.log('视频容器最大高度应为：',total_height);
			if (Box_videoWidth > Box_videoHeight) {
				$(document).ready(function(){
				$("#dplayer-{$i}-{$id}").attr("style", "width:100%;");
				});
			} else {
				$(document).ready(function(){
				$("#dplayer-{$i}-{$id}").attr("style", "width:40%;");
				});
			}
	
		}
		
	{/loop}
	
	{/if}
	
	

	
	// 获取所有audios
	var videos = document.getElementsByTagName("video");
	// 暂停函数
	function pausesAll() {
	    var self = this;
	    [].forEach.call(videos, function (i) {
	        // 将videoss中其他的video全部暂停
	        i !== self && i.pause();
	    })
	}
	// 给play事件绑定暂停函数
	[].forEach.call(videos, function (i) {
	    i.addEventListener("play", pausesAll.bind(i));
	})
</script>